﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataIssueRecord" @search="()=>{getTableDataIssueRecord();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StationId_FormItem" prop="StationId" :label="$t('message.autotrans._Model_IssueRecord_Station')">
            <el-select v-model="searchDataIssueRecord.StationId" clearable>
               <el-option v-for="item in stateIssueRecord.AllStations" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpId_FormItem" prop="OpId" :label="$t('message.autotrans._Model_IssueRecord_OpId')">
            <el-input v-model="searchDataIssueRecord.OpId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpName_FormItem" prop="OpName" :label="$t('message.autotrans._Model_IssueRecord_OpName')">
            <el-input v-model="searchDataIssueRecord.OpName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="IssueTypeId_FormItem" prop="IssueTypeId" :label="$t('message.autotrans._Model_IssueRecord_IssueType')">
            <el-select v-model="searchDataIssueRecord.IssueTypeId" clearable>
               <el-option v-for="item in stateIssueRecord.AllIssueTypes" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="IssueTypeName_FormItem" prop="IssueTypeName" :label="$t('message.autotrans._Model_IssueRecord_IssueTypeName')">
            <el-input v-model="searchDataIssueRecord.IssueTypeName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ReportTime_FormItem" prop="ReportTime" :label="$t('message.autotrans._Model_IssueRecord_ReportTime')">
            <el-date-picker v-model="searchDataIssueRecord.ReportTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Reporter_FormItem" prop="Reporter" :label="$t('message.autotrans._Model_IssueRecord_Reporter')">
            <el-input v-model="searchDataIssueRecord.Reporter" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Description_FormItem" prop="Description" :label="$t('message.autotrans._Model_IssueRecord_Description')">
            <el-input v-model="searchDataIssueRecord.Description" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Handler_FormItem" prop="Handler" :label="$t('message.autotrans._Model_IssueRecord_Handler')">
            <el-input v-model="searchDataIssueRecord.Handler" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="HandleTime_FormItem" prop="HandleTime" :label="$t('message.autotrans._Model_IssueRecord_HandleTime')">
            <el-date-picker v-model="searchDataIssueRecord.HandleTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="HandleResult_FormItem" prop="HandleResult" :label="$t('message.autotrans._Model_IssueRecord_HandleResult')">
            <el-input v-model="searchDataIssueRecord.HandleResult" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Status_FormItem" prop="Status" :label="$t('message.autotrans._Model_IssueRecord_Status')">
            <el-select v-model="searchDataIssueRecord.Status" clearable>
               <el-option key="Pending" value="Pending" :label="$t('message.autotrans._Enum_IssueStatusEnum_Pending')"></el-option>
               <el-option key="Handling" value="Handling" :label="$t('message.autotrans._Enum_IssueStatusEnum_Handling')"></el-option>
               <el-option key="Resolved" value="Resolved" :label="$t('message.autotrans._Enum_IssueStatusEnum_Resolved')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Remark_FormItem" prop="Remark" :label="$t('message.autotrans._Model_IssueRecord_Remark')">
            <el-input v-model="searchDataIssueRecord.Remark" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_IssueRecord_CreateTime')">
            <el-date-picker v-model="searchDataIssueRecord.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_IssueRecord_UpdateTime')">
            <el-date-picker v-model="searchDataIssueRecord.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_IssueRecord_CreateBy')">
            <el-input v-model="searchDataIssueRecord.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_IssueRecord_UpdateBy')">
            <el-input v-model="searchDataIssueRecord.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/AndonManagement/IssueRecord/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/AndonManagement/IssueRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/AndonManagement/IssueRecord/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/AndonManagement/IssueRecord/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/AndonManagement/IssueRecord/IssueRecordExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefIssueRecord" v-bind="tableDataIssueRecord">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/AndonManagement/IssueRecord/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/AndonManagement/IssueRecord/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/AndonManagement/IssueRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageAndonManagementIssueRecordIndex;true;Digitalmes.AndonManagement.Controllers;IssueRecord">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { issuerecordApi } from '/@/api/andonmanagement/issuerecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateIssueRecord = reactive({
    
    AllStations: [] as any[],
    AllIssueTypes: [] as any[],
});

const searchDataIssueRecord = ref({
        StationId: null,
        OpId: null,
        OpName: '',
        IssueTypeId: null,
        IssueTypeName: '',
        ReportTime: undefined,
        Reporter: '',
        Description: '',
        Handler: '',
        HandleTime: undefined,
        HandleResult: '',
        Status: undefined,
        Remark: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefIssueRecord = ref();
const tableDataIssueRecord = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page站点'),key: 'IssueRecord_Station',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page问题工位'),key: 'IssueRecord_OpId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位名称'),key: 'IssueRecord_OpName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page问题类型'),key: 'IssueRecord_IssueType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page问题名称'),key: 'IssueRecord_IssueTypeName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page上报时间'),key: 'IssueRecord_ReportTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page上报人'),key: 'IssueRecord_Reporter',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page问题描述'),key: 'IssueRecord_Description',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page处理人'),key: 'IssueRecord_Handler',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page处理时间'),key: 'IssueRecord_HandleTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page处理结果'),key: 'IssueRecord_HandleResult',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page状态'),key: 'IssueRecord_Status',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page备用'),key: 'IssueRecord_Remark',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'IssueRecord_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'IssueRecord_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'IssueRecord_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'IssueRecord_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataIssueRecord = () => {
    tableRefIssueRecord.value.doSearch(issuerecordApi().search, searchDataIssueRecord.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataIssueRecord)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataIssueRecord)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataIssueRecord)
};

// 删除
const onDelete = (row: any) => {
    issuerecordApi().delete([row.ID]).then(() => { getTableDataIssueRecord()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefIssueRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      issuerecordApi().delete(selectedids).then(() => { getTableDataIssueRecord()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefIssueRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataIssueRecord)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataIssueRecord)
};

const onExport = () => {
	const selected = tableRefIssueRecord.value.getSelectedRows();
	if (selected.length > 0) {
		issuerecordApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		issuerecordApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/AndonManagement/IssueRecord/GetAndonStations',[],false).then(x=>{stateIssueRecord.AllStations = x});
    other.getSelectList('/api/AndonManagement/IssueRecord/GetIssueTypes',[],false).then(x=>{stateIssueRecord.AllIssueTypes = x});
        getTableDataIssueRecord();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

